package com.jt.model;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * Created by he on 2015/9/12.
 */
public class Customer {

    private String name;
    private List<Rental> rentals;

    public Customer(String name) {
        this.name = name;
        this.rentals = Lists.newArrayList();
    }

    public String getName() {
        return name;
    }

    public void addRental(Rental rental) {
        this.rentals.add(rental);
    }

    public String stat() {
        String res = "客户: " + getName() + "\n";
        double total = 0.0;
        int points = 0;
        for (Rental rental : rentals) {
            double thisAmount = rental.getAmount();
            total += thisAmount;
            points += rental.getPoint();
            res += "你租用的" + rental.getMovie().getName() + "金额为" + thisAmount + ", 租期为" + rental.getDays();
            res += "获得的积分为" + points + "\n";
        }
        res += "你总消费" + total + ",总积分" + points;
        return res;
    }



}
